import 'package:flutter_todolist/pages/auth/auth_login.dart';
import 'package:flutter_todolist/pages/home/home.dart';
import 'package:flutter_todolist/pages/info_setting/info_setting.dart';
import 'package:flutter_todolist/utils/get_storage.dart';
import 'package:get/get.dart';

import '../db/table/user_table.dart';

class Auth {
  static void login(User user) {
    AppStorage().write(AppStorage.UserInfo, user.toJson());
    if (user.name == "") {
      Get.to(() => InfoSetting(userInfo: user), transition: Transition.rightToLeft);
    } else {
      Get.to(() => const Home());
    }
  }

  static void logOut() {
    AppStorage().remove(AppStorage.UserInfo);
    Get.offAll(() => AuthPage());
  }
}